package com.fasteat.mall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasteat.mall.entity.BoughtHistory;
import com.fasteat.mall.entity.VisitedHistory;
import com.fasteat.mall.entity.vo.ProductVisitedHistoryVo;
import com.fasteat.mall.mapper.BoughtHistoryMapper;
import com.fasteat.mall.mapper.VisitedHistoryMapper;
import com.fasteat.mall.service.BoughtHistoryService;
import com.fasteat.mall.service.VisitedHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BoughtHistoryServiceImpl extends ServiceImpl<BoughtHistoryMapper, BoughtHistory> implements BoughtHistoryService {

//	@Autowired
//	private BoughtHistoryMapper boughtHistoryMapper;
//
//	@Override
//	public List<ProductBoughtHistoryVo> getAllProductVisitedHistoriesByUserId(String userId) {
//		return boughtHistoryMapper.findAllProductVisitedHistoriesByUserId(userId);
//	}
//
//	@Override
//	public boolean removeAllAllProductVisitedHistoriesByUserId(String userId) {
//		return boughtHistoryMapper.deleteAllProductVisitedHistoriesByUserId(userId) > 0;
//	}
//
//	@Override
//	public Page<ProductBoughtHistoryVo> getAllProductVisitedHistoriesByUserIdWithPage(String userId, int current, int size) {
//		if (current <= 0) {
//			current = 1;
//		}
//		if (size <= 0) {
//			size = 5;
//		}
//		Page<ProductBoughtHistoryVo> page = new Page<>(current, size);
//		List<ProductBoughtHistoryVo> records = boughtHistoryMapper.findAllProductVisitedHistoriesByUserIdWithPage(userId, (current - 1) * size, size);
//		int total = boughtHistoryMapper.findCountByUserId(userId);
//		page.setRecords(records);
//		page.setTotal(total);
//		page.setPages(total / size + total % size == 0 ? 0 : 1);
//		return page;
//	}
}
